package com.arwtec.util;

import com.arwtec.model.ResultModel;

public class ResultResponseUtil {

    public static ResultModel success(){
        return success(200,"成功", true, null);
    }

    public static ResultModel success(Integer code, String msg, Boolean success, Object data) {
        ResultModel model = new ResultModel();
        if (code != null) model.setCode(code);
        if (msg != null) model.setMsg(msg);
        if (success != null) model.setSuccess(success);
        if (data != null) model.setData(data);
        return model;
    }

    public static ResultModel fail(){
        return error(400,"获取失败", false,null);
    }

    public static ResultModel fail(Integer code, String msg, Boolean success, Object data) {
        ResultModel model = new ResultModel();
        if (code != null) model.setCode(code);
        if (msg != null) model.setMsg(msg);
        if (success != null) model.setSuccess(success);
        if (data != null) model.setData(data);
        return model;
    }

    public static ResultModel error(){
        return error(500,"服务错误", false,null);
    }

    public static ResultModel error(Integer code, String msg, Boolean success, Object data) {
        ResultModel model = new ResultModel();
        if (code != null) model.setCode(code);
        if (msg != null) model.setMsg(msg);
        if (success != null) model.setSuccess(success);
        if (data != null) model.setData(data);
        return model;
    }
}
